import datetime

import pika

username = 'root'
password = '123456'

credentials = pika.credentials.PlainCredentials(username, password)
parameters = pika.ConnectionParameters(host='localhost', credentials=credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()

# 没有则创建队列
channel.queue_declare(queue='delay_queue2', arguments={'x-message-ttl': 1000*10})


def callback(_channel, method, properties, body):
    print(f"[{datetime.datetime.now()}] Received {body}")


channel.basic_consume('hello', callback)
channel.start_consuming()
